﻿using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Sumc.Client.ModernUI.Extensions
{
    public static class IEnumerableExtensions
    {
        public static IEnumerable<T> AddItemsToEnumeration<T>(this IEnumerable<T> enumeration, params T[] items)
        {
            if (enumeration != null)
            {
                foreach (var item in enumeration)
                {
                    yield return item;
                }
            }

            foreach (var item in items)
            {
                yield return item;
            }
        }

        public static IEnumerable<T> RemoveItemsFromEnumeration<T>(this IEnumerable<T> enumeration, params T[] items)
        {
            foreach (var item in enumeration)
            {
                var isNeededItem = true;
                foreach (var itemForRemove in items)
                {
                    if (item.Equals(itemForRemove))
                    {
                        isNeededItem = false;
                        break;
                    }
                }

                if (isNeededItem)
                {
                    yield return item;
                }
            }
        }
    }
}